package com.allbluefish.learn.web.action;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class UserController {

	@RequestMapping(value = "/login/{user}", method = RequestMethod.GET)
	public ModelAndView myMethod(@PathVariable("user") String user,
			ModelMap modelMap) throws Exception {
		modelMap.put("loginUser", user);
		return new ModelAndView("/login/hello", modelMap);
	}

	@RequestMapping(value = "/welcome", method = RequestMethod.GET)
	public String registPost() {
		return "/welcome";
	}

	@RequestMapping("/noPara")
	public void noParameter() {
		System.out.println("show some word!");
	}

	@RequestMapping("/start/{name}")
	public String oneParameter(@PathVariable("name") String name) {
		System.out.println(name);
		return "/welcome";

	}

	@RequestMapping("/start/{name}/{age}")
	public String anyParameter(@PathVariable("name")String name, @PathVariable("age")int age) {
		System.out.println(name);
		System.out.println(age);
		return "/welcome";

	}
	
}
